<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="./js/jquery-1.11.3.js"></script>
<script type="text/javascript">
function del(id){
	$.ajax({
		url : "json/delUser.action",
		type : "POST",
		contentType : "application/json",
		data : '{"id":"'+id+'"}',
		dataType : "json",
		success: function(data){
			var dataResult = data["dataResult"];
			var message = dataResult.message;
			alert(message);
			window.location.reload();
		},
		error: function(data){
		}
	});
}
function edit(id){
	  window.location.href="edituser.html?id="+id; 
}
$(function(){
	$.ajax({
		url : "json/showUser.action",
		type : "POST",
		dataType : "json",
		success: function(data){
			var dataResults = data["dataResults"]
			var userlist = dataResults.results;
			$.each(userlist,function(i,item){
				var content = "";
				var id = item["id"];
				var user = item["user"];
				var pwd = item["pwd"];
				var name = item["name"];
				var tel = item["tel"];
				var addre = item["addre"];
				var birth = item["birth"];
				var purview = item["purview"];
				content += "<fieldset>";
				content += "<legend>主键"+id+"</legend>";
				content += "用户名：'"+user+"'<br>";
				content += "密码：'"+pwd+"'<br>";
				content += "名字：'"+name+"'<br>";
				content += "电话：'"+tel+"'<br>";
				content += "地址：'"+addre+"'<br>";
				content += "生日：'"+birth+"'<br>";
				content += "权限：'"+purview+"'";
				content += "<button onclick='del("+id+")' style='width: 100px;height: 25px;'>删除</button>";
				content += "<button onclick='edit("+id+")' style='width: 100px;height: 25px;'>修改</button>";
				content += "</fieldset>";
				$("#content").append(content);
			});
			 
		},
		error: function(){
		}
	});
});
</script>
</head>
<body>
<div id="content">
</div>
</body>
</html>